<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateWorkWechatUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('work_wechat_users', function (Blueprint $table) {
            $table->id();
            // 满足多企业场景需求
            $table->string('corp_id')->comment('企业ID');
            $table->string('userid')->comment('用户ID');
            $table->string('name')->nullable()->comment('用户名');
            $table->string('avatar')->nullable()->comment('头像');
            // 列表项为部门ID，32位整型
            $table->text('department')->nullable()->comment('所属部门列表');
            // 全局唯一。对于同一个服务商，不同应用获取到企业内同一个成员的open_userid是相同的，最多64个字节。仅第三方应用可获取
            $table->string('open_userid')->nullable();
            $table->text('userinfo')->nullable()->comment('用户ID');
            $table->timestamps();
        });
        \DB::statement("ALTER TABLE `work_wechat_users` comment '企业微信用户成员表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('work_wechat_users');
    }
}
